package com.guanghua.brick.html.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;

import com.guanghua.brick.html.IControl;

public class PermissionItemTag extends BodyTagSupport {
	//private static Log logger = LogFactory.getLog(PermissionItemTag.class);
	
	private String function = null;
	private boolean avail = true;

	public int doEndTag() throws JspException {
		if (avail) {
			Tag parent = this.getParent();
			if (parent instanceof PermissionFunctionTag) {
				((PermissionFunctionTag)parent).setFunction(this.function);
			} else if (parent instanceof IControl) {
				((IControl)parent).setFunction(this.function);
			}
		}
		return BodyTagSupport.EVAL_PAGE;
	}

	public boolean isAvail() {
		return avail;
	}

	public void setAvail(boolean avail) {
		this.avail = avail;
	}

	public String getFunction() {
		return function;
	}

	public void setFunction(String function) {
		this.function = function;
	}
}
